package com.zhengsr;

import android.content.Context;
import android.os.Handler;

/**
 * Created by zhengshaorui
 * time: 2018/8/19
 * 一个统一管理的初始化配置
 */

public class CoreManager {
    private static Builder mBuilder;
    private CoreManager(Builder builder){
        mBuilder = builder;
    }

    public static Builder configBuilder(){
        return new Builder();
    }


    public static Handler getHandler(){
        return mBuilder.handler;
    }

    public static int getScreenWidth(){
        return mBuilder.context.getResources().getDisplayMetrics().widthPixels;
    }

    public static Context getContext(){
        return mBuilder.context;
    }

    public static String getBaseUrl(){
        return mBuilder.baseUrl;
    }

    public static class Builder{
        Context context;
        Handler handler;
        String baseUrl;

        public Builder setContext(Context context) {
            this.context = context;
            return this;
        }

        public Builder setHandler(Handler handler) {
            this.handler = handler;
            return this;
        }

        public Builder setBaseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
            return this;
        }

        public CoreManager builder(){
            return new CoreManager(this);
        }

    }
}
